package com.itheima._07静态泛型方法和通配符上下限;

/**
 * @Description Demo071
 * @Author GreenHand_Lu
 * @Date 2025-07-19
 */
class Student{}
class Teacher{}

public class Demo071 {

    public static void main(String[] args) {

        Student[] students = {new Student(),new Student()};
        Teacher[] teachers = {new Teacher(),new Teacher(),new Teacher()};
        printLength(students);
        printLength(teachers);
    }

    //泛型静态方法注意必须加<T>
    //打印任何类型数组长度
    //方式1
    public static <T> void printLength(T[] arr){
        System.out.println(arr.length);
    }

    //方式2
    public static void printLength2(Object[] arr){
        System.out.println(arr.length);
    }
}
